package com.agileboot.domain.airport.selfcheck.query;

import cn.hutool.core.util.StrUtil;
import com.agileboot.common.annotation.ExcelColumn;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.agileboot.domain.airport.selfcheck.db.SirSelfCheckEntity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class SirSelfCheckQuery extends AbstractPageQuery<SirSelfCheckEntity> {

    @ExcelColumn(name = "专业")
    private String professional;

    @ExcelColumn(name = "检查内容")
    private String checkContent;

    @ExcelColumn(name = "检查标准编号")
    private String checkStandardCode;

    @ExcelColumn(name = "检查标准")
    private String checkStandard;

    @ExcelColumn(name = "符合性判定标准")
    private String complianceCriteria;

    @ExcelColumn(name = "检查方式")
    private String checkMethod;

    @ExcelColumn(name = "公司依据")
    private String companyBasis;

    @ExcelColumn(name = "公司条款")
    private String companyClause;

    @ExcelColumn(name = "法律法规依据")
    private String lawsBasis;

    @ExcelColumn(name = "法律法规条款")
    private String lawsClause;

    @ExcelColumn(name = "基础周期")
    private String baseCycle;

    @ExcelColumn(name = "融合来源")
    private String integrationSource;

    @ExcelColumn(name = "检查涉及部门")
    private String checkDepartments;

    @ExcelColumn(name = "归属部门")
    private Long belongDept;

    // 新增检查ID搜索条件
    @ExcelColumn(name = "检查ID")
    private Long inspectionId;

     @ExcelColumn(name = "标签ID")
    private Long tagId;



    @Override
    public QueryWrapper<SirSelfCheckEntity> addQueryCondition() {
        QueryWrapper<SirSelfCheckEntity> queryWrapper = new QueryWrapper<>();

        // 专业查询
        queryWrapper.eq(StrUtil.isNotEmpty(professional), "professional", professional);


        queryWrapper.eq(belongDept != null, "belong_dept", belongDept);
        queryWrapper.eq(tagId != null, "tag_id", tagId);



        // 检查内容查询（模糊匹配）
        queryWrapper.like(StrUtil.isNotEmpty(checkContent), "check_content", checkContent);

        // 检查标准编号查询（精确匹配）
        queryWrapper.eq(StrUtil.isNotEmpty(checkStandardCode), "check_standard_code", checkStandardCode);

        // 检查标准查询（模糊匹配）
        queryWrapper.like(StrUtil.isNotEmpty(checkStandard), "check_standard", checkStandard);

        // 符合性判定标准查询（模糊匹配）
        queryWrapper.like(StrUtil.isNotEmpty(complianceCriteria), "compliance_criteria", complianceCriteria);

        // 检查方式查询（模糊匹配）
        queryWrapper.like(StrUtil.isNotEmpty(checkMethod), "check_method", checkMethod);

        // 公司依据查询（模糊匹配）
        queryWrapper.like(StrUtil.isNotEmpty(companyBasis), "company_basis", companyBasis);

        // 公司条款查询（模糊匹配）
        queryWrapper.like(StrUtil.isNotEmpty(companyClause), "company_clause", companyClause);

        // 法律法规依据查询（模糊匹配）
        queryWrapper.like(StrUtil.isNotEmpty(lawsBasis), "laws_basis", lawsBasis);

        // 法律法规条款查询（模糊匹配）
        queryWrapper.like(StrUtil.isNotEmpty(lawsClause), "laws_clause", lawsClause);

        // 基础周期查询（精确匹配）
        queryWrapper.eq(StrUtil.isNotEmpty(baseCycle), "base_cycle", baseCycle);

        // 融合来源查询（精确匹配）
        queryWrapper.eq(StrUtil.isNotEmpty(integrationSource), "integration_source", integrationSource);

        // 检查涉及部门查询（精确匹配）
        queryWrapper.eq(StrUtil.isNotEmpty(checkDepartments), "check_departments", checkDepartments);
        // 新增检查ID查询（精确匹配）
        queryWrapper.eq(inspectionId != null, "inspection_id", inspectionId);

        // 添加时间范围查询
        this.setTimeRangeColumn("create_time");

        return queryWrapper;
    }
}
